home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / challenge / 12.04-Apr96 / LifeTestCode DR3.sit / Life TestCode DR3 / LifeScramble.c < prev    next >
Text File  |  1996-04-01  |  1KB  |  45 lines

  1. /* LifeScramble.c    */
  2. /* ©Ludovic Nicolle 1996    */
  3.  
  4.  
  5. /* 
  6. this file contain the code of the function responsible for
  7. bitmap initialization.
  8.  
  9. The following are true:
  10.  
  11. -    the GrafPort pointed by inputCellsPort exists and the BitMap has
  12.     already been allocated.
  13.  
  14. -    GrafPort has also been erased so the world is empty.
  15.  
  16. -    GetPort/SetPort is done by the caller, so InitCellsPort don't 
  17.     have to bother if it doesn't change the port.
  18.  
  19. */
  20.  
  21. #include "LifeScramble.h"
  22.  
  23.  
  24. void InitCellsPort(GrafPtr inputCellsPort)
  25. {
  26. /*    sample initialization draws small ovals in the bitmap    */
  27. /*    replace with your own code if needed                    */
  28.     Point        mybounds;
  29.     short        i, limit;
  30.     Rect        drawRect;
  31.     
  32.     limit = Random() & 0xFF;
  33.     mybounds = botRight(inputCellsPort->portBits.bounds);
  34.     
  35.     for(i = 0; i < limit; i++)
  36.     {
  37.         drawRect.top = (Random() & 0x7FFF) % mybounds.v;
  38.         drawRect.left = (Random() & 0x7FFF) % mybounds.h;
  39.         drawRect.bottom = drawRect.top + (Random() & 0x0F);
  40.         drawRect.right = drawRect.left + (Random() & 0x0F);
  41.         
  42.         InvertOval(&drawRect);
  43.     }
  44. }
  45.